<%@ page language="java" pageEncoding="utf-8"%>
<%
String baseUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
%>
<!DOCTYPE html>
<html>
<base href="<%=baseUrl%>"/>
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="static_front/css/bootstrap.min.css">
	<title>用户登录</title>
</head>


<div class="container" style="margin-top: 50px">
	<div class="row center" style="margin-bottom: 50px">
		<div class="col-md-12 text-center"><h1>用户登录</h1></div>
	</div>
	<div class="row">
		<div class="col-md-3"></div>
		<div class="col-md-6">
			<% 
			String username = null, password = null;
			//获取cookie，填充到表单
			Cookie[] cookies = request.getCookies();
			if(cookies!=null) {
				if(cookies.length>0){
					for(Cookie c:cookies){
						//遍历所有cookie，去拿我们想要的两个cookie
						if(c.getName().equals("username")) {
							username = c.getValue();
						}
						if(c.getName().equals("password")) {
							password = c.getValue();
						}
					}
				}
			}
			if(request.getParameter("code")!=null && request.getParameter("code").equals("-1")){
			%>
			<div class="form-group row">
				<label class="col-md-2"></label>
				<div class="col-md-5">		
					<span class='text-danger'>用户名或密码有误..</span>
				</div>
				<span id="msgUsername"></span>
			</div>
			<%
			}
			%>
			<form action="login" method="post">
				<div class="form-group row">
					<label class="col-md-2">用户名</label>
					<div class="col-md-5">		
						<input type="text" name="username" class="form-control" value="<%if(username!=null) out.print(username);%>">
					</div>
					<span id="msgUsername"></span>
				</div>
				<div class="form-group row">
					<label class="col-md-2">密码</label>
					<div class="col-md-5">		
						<input type="password" name="password" class="form-control" value="<%if(password!=null) out.print(password);%>">
					</div>
					<span id="msgUsername"></span>
				</div>
				<div class="form-group row">
					<label class="col-md-2"></label>
					<div class="col-md-5">		
						<input type="checkbox" name="autoLogin" value="1" class="form-control1"> 自动登录
					</div>
				</div>
				<div class="form-group row">
					<label class="col-md-2"></label>
					<div class="col-md-10">
						<input type="hidden" name="action" value="login"/>
						<input type="submit" value="登录" name="submit" class="btn btn-danger"> <a href="reg.jsp">注册</a>
					</div>
				</div>
			</form>
		</div>
		<div class="col-md-3"></div>
	</div>

</div>

<script type="text/javascript" src="static_front/js/jquery.min.js"></script>
<script type="text/javascript" src="static_front/js/bootstrap.min.js"></script>
<script type="text/javascript">
	
</script>